package cn.tedu._05mvcboot034.common.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    private String message;
    private Integer state;
    private Object data;
    public JsonResult( StatusCode state) {
        this.state = state.getState();
        this.message = state.getMessage();
    }
    public JsonResult( StatusCode state, Object data) {
        this.state = state.getState();
        this.message = state.getMessage();
        this.data = data;
    }
    public static JsonResult ok(Object data) {
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }
    public static JsonResult ok() {
        return ok(null);
    }
}
